<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page import="com.tjtt.tdm.base.PubMethod"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   
	<head>
		<%@ include file="../jslib/jquerylib.jsp" %>
		<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
		<script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
	    <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
		<script type="text/javascript">
         var api = frameElement.api;
         if (api!=undefined)
         {
         	var W = api.opener;
         }
        </script>
         <c:if test="${requestScope.message != null}">
         	<script type="text/javascript">
         		 alert("<c:out value='${requestScope.message}'></c:out>");
	         	 api.close();
	         	 //W.reload();
	         </script>
         </c:if>
		<script type="text/javascript">
		     var flowid = '2481';
			 var addpath = '';
			 var FId='';
			 $.ajax({
				type: "POST",
				async: false,//取消异步提交
				url: 'flowformAction!getAddpath.action?flowid='+flowid,
				dataType: "json",
				success : function(data, textStatus) {  
					addpath = data.addpath;
				}
			});
			
			 $(document).ready(function(){
				$("#gridTable").jqGrid({
					url:'<%=request.getContextPath() %>/reportUpdateAction!queryReportData.action?id=${param.id}',
					datatype: "json",
					height: 360,
					autowidth: true, 
					colNames:['主键','流程名称','流程类型','taskinfoId','任务名称','任务标识号','委托人','委托时间','流程类型id','表名'],
					colModel:[
						{name:'ID',index:'ID', width:40,key:true,sorttype:"int"}, 
						{name:'FLOW_NAME',index:'FLOW_NAME', width:220}, 
						{name:'FLOWTYPEID',index:'FLOWTYPEID',hidden:true,width:220},
						{name:'TASKINFOID',index:'TASKINFOID',hidden:true,width:220},
						{name:'RENWUNAME',index:'RENWUNAME', width:150},
						{name:'WEITUODANSHIBIENO',index:'WEITUODANSHIBIENO',hidedlg:true},
						{name:'LIANXIREN',index:'LIANXIREN',width:80,hidedlg:true},
						{name:'SHENQINGDATE',index:'SHENQINGDATE',hidedlg:true},
						{name:'TASKID',index:'TASKID',hidden:true,hidedlg:true},
						{name:'TABLE_NAME',index:'TABLE_NAME',hidden:true,hidedlg:true}
					], 
					shrinkToFit:false,
					sortname:'ID',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					rownumbers: false,//显示行号
					editable:true, 
					rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					subGrid: true,
					subGridRowExpanded: function(subgrid_id, row_id) {
					   var rowData = $("#gridTable").getRowData(row_id); 
				       var subgrid_table_id;
				       subgrid_table_id = subgrid_id+"_t";
				       subtableName = subgrid_id+"_t";
				       FId = subgrid_id;
				       var row = jQuery("#gridTable").jqGrid('getRowData',row_id);
				       FTaskId = row.TASKID;
				       jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>");
				       jQuery("#"+subgrid_table_id).jqGrid({
				    	   url:common_basePath+'reportUpdateAction!queryReportList.action?taskId='+row.TASKID+'&temp='+Math.round(Math.random()*10000),
				    	    datatype: "json", 
							colNames:['主键','检测项目','项目状态id','项目状态','原始记录路径','报告路径','报告识别号','报告要求'],
							colModel:[{name:'ID',index:'ID',key:true,hidden:true, width:100,hidedlg:true},
					          {name:'T_ITEMNAME',index:'T_ITEMNAME', width:140},
					          {name:'FLOW_STATE_ID',index:'FLOW_STATE_ID', width:180,hidden:true},
					          {name:'FLOW_STATE_NAME',index:'FLOW_STATE_NAME', width:110},
					          {name:'T_YSJLFILEPATH',index:'T_YSJLFILEPATH', width:140}, 
							  {name:'T_BGFILEPATH',index:'T_BGFILEPATH', width:140},
							  {name:'T_REPORTSHIBIEH',index:'T_REPORTSHIBIEH', width:140},  
							  {name:'T_BAOGAOTYPE',index:'T_BAOGAOTYPE', width:100} 
					        ], 
							jsonReader: {
								root:"rows",		// 数据行（默认为：rows）
								page: "page",  	// 当前页
								total: "total",  // 总页数
								records: "records",  // 总记录数
								repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
							},
							shrinkToFit:false,
						    height:"auto", 
						    multiselect: true, 
						    width:780,
							rowNum:500,
							sortname:'ID',
							sortorder:'asc'
				       });
				   },
					ondblClickRow:function(rowid,iRow,iCol,e){
						viewBiaodan();
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "报告列表"
				});
			});
	        
	        //刷新页面
			function shuaXin(){
			 //  document.location.href='haslaunched_worklist.jsp'; 
			  jQuery("#gridTable").jqGrid('setGridParam',
                    {
                        url:'waitWork.action'
                    }).trigger("reloadGrid", [{page:1}]); 
	        }
			function reload(){
			   location.reload();
	        }
	         
	    //查询
		function gridSearch(){
			var jdmc = jQuery("#jdmc").val();
			var rwmc = jQuery("#rwmc").val();
			var params = {  
	            "jdmc" : encodeURIComponent($.trim(jdmc)),
	            "rwmc" : encodeURIComponent($.trim(rwmc))
			};							 
			 var postData = $("#gridTable").jqGrid("getGridParam", "postData");
			 $.extend(postData, params);
			jQuery("#gridTable").jqGrid('setGridParam',
			{
				url:'waitWork!queryWaitWorkExec.action'
			}).trigger("reloadGrid", [{page:1}]); 
        } 
		//修改报告
		function updateBG(operate_type){
		
			var ids = $("#"+subtableName).jqGrid("getGridParam", "selarrrow") + "";
			var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
		    if (!ids) {
		       alert("请先选择记录!");  
		       return false;  
			}
			if(ids.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			}
			/* if(row.FLOW_STATE_ID != "end"){
				alert("报告未发放，不能修改!");  
		       	return false;  
			} */
			var ids1= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
			if (!ids1) {
		       alert("请先选择记录!");  
		       return false;  
			}
			var row1 = jQuery("#gridTable").jqGrid('getRowData',ids1);//获取选中行.
			var id = row1.ID;//获取选中行的id属性.
			FTaskId = row1.TASKID;
			var baogaopath=row.T_BGFILEPATH;
			var baogaono = row.T_REPORTSHIBIEH;
	           //流程图中表单：手写的路径
	       var arr = addpath.split(",");
	       $.dialog({
		        title: '报告修改',
		        content: 'url:'+ '<%=request.getContextPath() %>/reportUpdateAction!queryWeituodanById.action?id='+id+'&baogaopath='+baogaopath+'&ids='+ids+'&FTaskId='+FTaskId+'&FId='+FId+'&baogaono='+baogaono+'&flowid='+flowid+'&formid='+arr[0]+'&temp='+Math.round(Math.random()*10000),
		        okVal: false,//确定按钮文字
		        cancelVal: false,//取消按钮文字
		        min: true, //是否显示最小化按钮
		        max: false,//是否显示最大化按钮
		        fixed: false,//开启静止定位
		        lock: true,//开启锁屏
		        focus: true,//弹出窗口后是否自动获取焦点（4.2.0新增）
		        time: null,//设置对话框显示时间
		        resize: true,//是否允许用户调节尺寸
		        drag: true,//是否允许用户拖动位置
		        cache: false,//是否缓存iframe方式加载的窗口内容页
		        width: '880px',
		        height:  550
			});
		}
		</script>
	</head>
	<body>
	<form action="" method="post">
	<input type="hidden" name="flowid" id="flowid" value="${flowid}" />
     	<input type="hidden" name="stateid" id="stateid" value="${stateid}" />
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
             <tr>
              <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
              <tr>
                <td width="10%" align="right">任务名称：</td>
                <td width="24%"><input type="text" name="rwmc" id="rwmc" class="search_InputText" style="width:99%;" /></td>
                <td width="10%" height="30" align="right">节点名称：</td>
                <td width="24%"><input type="text" name="jdmc" id="jdmc" class="search_InputText" style="width:99%;" /></td>
                <td width="7%" align="left">&nbsp;</td>
                <td width="25%" align="right"><input name="button" type="button" class="search_Btn" onclick="gridSearch()"  value="查询" />
                &nbsp;&nbsp;
                <input name="button2" type="button" class="search_Btn" onclick="reset()" value="清空" /></td>
              </tr>
              </td></tr>
          </table>
		 <table style="width: 100%;" class="tableCont">
			<tr>
				<td>
					<input type='button' value='申请修改' onclick="updateBG('0')" class='button_b' />
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<table id="gridTable"></table>
					<div id="gridPager"></div>
				</td>
			</tr>
		 </table>
		</form>
	</body>
</html>
